<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <h1>{{name}}</h1>
        <!-- v-model 它是 :vlaue 和  @input的结合体 -->
        <input type="text" v-model='todo' @keydown.enter='submit'>
        <ul>
          <li v-for='(item,index) in ary' :key='item.id'>
            <input type="checkbox">
            {{item.todo}}
            <button @click='del(index)'>X</button>
          </li>
        </ul>
    </div>
</body>
</html>
<script src="../../node_modules/vue/dist/vue.js"></script>
<script>
    let vm = new Vue({
        el:'#app',
        data:{
            name:"珠峰",
            todo:'',
            ary:[]
        },
        methods: {
          submit(){
            this.ary.unshift({todo:this.todo,id:Math.random()})
            this.todo = '';
            // console.log(this.todo)
          },
          del(n){
            this.ary.splice(n,1)
          }
        },
    });
</script>